package com.nf.health.app.bodyfat.util;


import com.nf.health.app.bodyfat.bean.IndexNormalBean;

/**
 * Created by he_pan on 2017/5/27.
 * The only genius that is worth anything is the genius for hard work
 *
 * @author he_pan
 */

public class BodyFatUtil {
    /**
     * 获得各项指标的正常值
     *
     * @param weight
     * @param height
     * @param sex
     * @param age
     * @return
     */
    public static IndexNormalBean getIndexNormarValue(float weight, String height, String sex, String age) {
        IndexNormalBean bean = new IndexNormalBean();
        float heightInt = Integer.valueOf(height);
        if (heightInt <= 10) {
            heightInt = 10;
        }
        if ("未填写".equals(age)) {
            age = "25";
        }
        int ageInt = Integer.valueOf(age);
        if (ageInt <= 1) {
            ageInt = 25;//默认25岁
        }

        if ("2".equals(sex)) {//女性
            //骨骼
            if (weight < 45) {
                bean.setSkeleton("1.5~2.1正常");
            } else if (weight > 60) {
                bean.setSkeleton("2.2~2.8正常");
            } else {
                bean.setSkeleton("1.9~2.5正常");
            }
            //肌肉
            if (heightInt < 160) {
                bean.setMuscle("29.1~34.7正常");
            } else if (heightInt > 170) {
                bean.setMuscle("32.9~37.5正常");
            } else {
                bean.setMuscle("36.5~42.5正常");
            }
            //水含量
            if (ageInt <= 30) {
                bean.setWater("52.9~49.5%正常");
            } else {
                bean.setWater("51.5~48.1%正常");
            }
            //内脏脂肪
            bean.setViscusFat("1~9正常");
            //基础代谢
            if (ageInt >= 50) {
                bean.setHeat("20.7正常");
            } else if (ageInt >= 30) {
                bean.setHeat("21.7正常");
            } else {
                bean.setHeat("23.6正常");
            }
            //身体脂肪
            if (ageInt >= 60) {
                bean.setFat("23~29%正常");
            } else if (ageInt >= 40) {
                bean.setFat("23~28%正常");
            } else {
                bean.setFat("21~27%正常");
            }
        } else {//默认男性
            //骨骼
            if (weight < 60) {
                bean.setSkeleton("2.0~3.0正常");
            } else if (weight > 75) {
                bean.setSkeleton("2.7~3.7正常");
            } else {
                bean.setSkeleton("2.4~3.4正常");
            }
            //肌肉
            if (heightInt < 160) {
                bean.setMuscle("38.5~46.5正常");
            } else if (heightInt > 170) {
                bean.setMuscle("49.4~59.4正常");
            } else {
                bean.setMuscle("44.0~52.4正常");
            }
            //水含量
            if (ageInt <= 30) {
                bean.setWater("57.0~53.6%正常");
            } else {
                bean.setWater("55.6~52.3%正常");
            }
            //内脏脂肪
            bean.setViscusFat("1~9正常");
            //基础代谢
            if (ageInt >= 50) {
                bean.setHeat("21.5正常");
            } else if (ageInt >= 30) {
                bean.setHeat("22.3正常");
            } else {
                bean.setHeat("24.0正常");
            }
            //身体脂肪
            if (ageInt >= 60) {
                bean.setFat("14~19%正常");
            } else if (ageInt >= 40) {
                bean.setFat("12~17%正常");
            } else {
                bean.setFat("11~16%正常");
            }
        }
        return bean;
    }
}
